# Contributor: Joseph Benden <joe@benden.us>
# Maintainer: Joseph Benden <joe@benden.us>
pkgname=stgit
pkgver=0.23
pkgrel=0
pkgdesc="Manage a stack of patches using GIT as a backend"
arch="noarch"
url="http://www.procode.org/stgit/"
license="GPL-2.0-or-later"
options="!check" # unit-tests fail due to iconv usage
depends="git python3"
makedepends="asciidoc xmlto perl"
subpackages="
	$pkgname-doc
	$pkgname-zsh-completion
	$pkgname-fish-completion
	$pkgname-bash-completion
	"
source="https://github.com/stacked-git/stgit/releases/download/v$pkgver/stgit-$pkgver.tar.gz"

prepare() {
	default_prepare

	# this will be a noop, as we are working with a tarball,
	# but throws git errors --> just get rid of it
	echo "version=\"$pkgver\"" > stgit/builtin_version.py
}

check() {
	make \
		PYTHON=python3 \
		prefix=/usr \
		mandir=/usr/share/man/ \
			test
}

build() {
	make \
		PYTHON=python3 \
		prefix=/usr \
		mandir=/usr/share/man/ \
			all doc
}

package() {
	make \
		DESTDIR="$pkgdir" \
		PYTHON=python3 \
		prefix=/usr \
		mandir=/usr/share/man/ \
			install install-doc

	install -Dm0644 "$pkgdir"/usr/share/stgit/completion/stgit.bash \
		"$pkgdir"/usr/share/bash-completion/completions/stgit
	install -Dm0644 "$pkgdir"/usr/share/stgit/completion/stgit.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_stgit
	install -Dm0644 "$pkgdir"/usr/share/stgit/completion/stg.fish \
		"$pkgdir"/usr/share/fish/completions/stg.fish

	rm -rf "$pkgdir"/usr/share/stgit/completions
}

sha512sums="7df61409225045f1738fc391c3053025ce79dfc980d5d420215e2a8cde3483de8ec9c1ddf2f2857d9e0ef84577cf1ad09423036b50ccf4ee5cf4144a6f1201bb  stgit-0.23.tar.gz"
